# include <bits/stdc++.h>
# include <sstream>
# include <fstream>
using namespace std;
const int monthList[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
const int perDay=24*3600;
int convertTime(int month,int day,int hour,int minute,int second){
	int curDay=0;
	for(int i=1;i<month;++i){
		curDay+=monthList[i];
	}
	return (curDay+day)*perDay+hour*3600+minute*60+second;
}
int getWorkTime(){
	ifstream inFile("records.txt");
	string line;
	vector<int> arr;
	long long  year,month,day,hour,minute,second,result=0;
	while(getline(inFile,line)){
		year=stoi(line.substr(0,4));
		month=stoi(line.substr(5,2));
		day=stoi(line.substr(8,2));
		hour=stoi(line.substr(11,2));
		minute=stoi(line.substr(14,2));
		second=stoi(line.substr(17,2));
		arr.push_back(convertTime(month,day,hour,minute,second));
	}
	sort(arr.begin(),arr.end());
	for(int i=0,size=arr.size();i<size;i=i+2){
		result+=arr[i+1]-arr[i];
	}
	return result;
}
int main(){
	cout<<getWorkTime()<<endl;
	return 0;
} 
